package com.fr.data.core.define;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;

public class SelectionColumn
  implements XMLReadable, Cloneable, Serializable
{
  private String name = null;
  private int columnIndex = -1;

  public SelectionColumn()
  {
  }

  public SelectionColumn(String paramString)
  {
    setName(paramString);
  }

  public SelectionColumn(int paramInt)
  {
    setColumnIndex(paramInt);
  }

  public SelectionColumn(String paramString, int paramInt)
  {
    setName(paramString);
    setColumnIndex(paramInt);
  }

  public SelectionColumn(String paramString1, String paramString2, Class paramClass)
  {
    setName(paramString1);
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }

  public int getColumnIndex()
  {
    return this.columnIndex;
  }

  public void setColumnIndex(int paramInt)
  {
    this.columnIndex = paramInt;
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("SelectionColumn");
    if (this.name != null)
      paramXMLPrintWriter.attr("name", this.name);
    if (this.columnIndex > -1)
      paramXMLPrintWriter.attr("columnIndex", this.columnIndex);
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      String str;
      if ((str = paramXMLableReader.getAttr("name")) != null)
        setName(str);
      if ((str = paramXMLableReader.getAttr("columnIndex")) != null)
        setColumnIndex(Integer.parseInt(str));
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof SelectionColumn))
      return false;
    SelectionColumn localSelectionColumn = (SelectionColumn)paramObject;
    return ((ComparatorUtils.equals(localSelectionColumn.getName(), getName())) && (localSelectionColumn.getColumnIndex() == getColumnIndex()));
  }

  public String toString()
  {
    if (getColumnIndex() > -1)
    {
      if (getName() == null)
        return "#" + (getColumnIndex() + 1);
      return "#" + (getColumnIndex() + 1) + " --- " + getName();
    }
    return getName();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}